<template>
	<view class="wrap">
		<view class="list">
			<view class="content" v-for="(item,index) in onDataList" :key="item.id">
				<view class="top acea-row row-between row-middle">
					<view class="left acea-row row-middle  ">
						<image src="@/static/images/user/business.png" mode="aspectFill"></image>
						<text class="enter_limit">{{item.storename}}</text>
					</view>
					<view class="right">￥300/人</view>
				</view>
				<view class="bottom acea-row row-between row-middle">
					<text :class="item.auditStatus == 1?'':'equie'">{{auditStatusDic[item.auditStatus]}}</text>
					<image src="" mode=""></image>
					<view class="contents">
						<view class="line">
							业态： {{item.businessName}}
						</view>
						<view class="line">
							联系人： {{item.contacts[0].contactName}} 
						</view>
						<view class="line">
							电话： {{item.contacts[0].contactPhone.replace(/(\d{3})\d*(\d{4})/,'$1****$2')}}
						</view>
						    好评度：{{item.avgScore}}
					</view>
				</view>
				<view class="line_bottom"></view>
				<view class="btns acea-row row-between" style="justify-content: flex-end;">
	<!-- 				<view class="btn">
						申请服务商
					</view>
					<view class="btn">
						生意转让
					</view>
					<view class="btn">
						关店
					</view> -->
					<view class="btn"  @click="toEdit(item.id)" style="margin-right: 22rpx;">
						编辑
					</view>
					<view class="btn" @click="toDelete(item.id)">
						删除
					</view>
				</view>
			</view>
	   </view>
	   <view class='loadingicon acea-row row-center row-middle' style="margin-top: 200rpx;">
	   	<text class='loading iconfont icon-jiazai' :hidden='loading'></text>{{loadTitle}}
	   </view>
	   <!-- 底部按钮 -->
	   <view class="publish_btn" @click="publish">新增生意</view>
	   </view>
</template>

<script>
	import {getPointOnList,delPonit} from '@/api/centerModule/index.js'
	var statusBarHeight = uni.getSystemInfoSync().statusBarHeight + 'px';
	export default {
		data() {
			return {
				statusBarHeight: statusBarHeight,
				city: '武汉',
				shareInfo: {},
				page:1,
				limit: 8,
				auditStatusDic:{
					'0':'待审',
					'1':'成功',
					'2':'驳回'
				},
				onDataList: [],
				loading: true,
				loadTitle:''
			}
		},
		created() {
			uni.hideTabBar()
			this.getPointOnList();
		},
		onShow() {
			// this.setOpenShare();
		},
		onHide() {},
		methods: {
			publish() {
				wx.navigateTo({
					url: '/pages/releases/addPoint/addPoint'
				})
			},
			toEdit(id){
				let that = this;
				uni.navigateTo({
					url:'/pages/releases/addPoint/addPoint?id='+ id,
					events:{
						upList:function(){
							that.page = 1;
							that.getPointOnList();
						}
					}
				})
			},
			onReachBottom: function() {
				if (this.isDiy) {
					this.$refs.diy.onsollBotton()
				}
			},
			// 数据请求
			getPointOnList(){
				this.loading = false;
				getPointOnList({
					page:this.page,
					limit: this.limit
				}).then(res=>{
					this.loading = true;
					if(this.page == 1){
						this.onDataList = res.data.list;
						if(this.onDataList.length<=0){
							this.loadTitle = "暂无数据"
						}
					}else{
						this.onDataList=this.onDataList.concat(res.data.list);
						if(res.data.list<=0){
							this.loadTitle = "已加载所有"
						}
					}
				})
			},
			toDelete(id){
				let that = this;
				uni.showModal({
				    title: '提示',
				    content: '你确定要删除吗',
				    success: function (res) {
				        if (res.confirm) {
				        	delPonit(id).then(res=>{
								that.page = 1;
				        		that.getPointOnList();
				        	})
				        } else if (res.cancel) {
				        	console.log('取消');
				        }
				    }
				});
			}
		},
		onReachBottom(){
			this.page++;
			this.getPointOnList();
		}
		
	}
</script>

<style scoped lang="scss">
	.wrap {
		padding-bottom: 160rpx;
	}
	.col_38 {
		color: #383838;
	}
	.col_A6 {
		color: #A6A6A6;
	}
	.mt_28 {
		margin-top: 28rpx;
	}
	.text_c {
		text-align: center;
	}
    .list {
     margin: 16rpx 28rpx 0;
	}
	.content {
		padding: 30rpx 26rpx;
		margin-top: 32rpx;
		background-color: #fff;
        border-radius: 10rpx;
		.top {
			height: 56rpx;
			padding-bottom: 14rpx;
			border-bottom: 2rpx solid #EEEEEE;

			.left {
				image {
					width: 32rpx;
					height: 32rpx;
					margin-right: 12rpx;
				}
			}
			.right {
				color: #D4D4D4;
				image {
					width: 38rpx;
					height: 26rpx;
					margin-right: 8rpx
				}
			}
		}
		.bottom {
			position: relative;
			margin: 16rpx 0;
			image {
				height: 144rpx;
				width: 170rpx;
				border-radius: 10rpx;
				margin-right: 22rpx;
			}
			.contents {
				flex: 1;
				color: #808080;
			}
			.line {
				word-break: break-all;
				line-height: 44rpx;
				font-size: 24rpx;
				color: #808080;
			}
			.equie {
				position: absolute;
				right: 0;
				top: 4rpx;
				color: #EE212D;
				font-size: 24rpx;
			}
			.limit {
				max-width: 350rpx;
			}
		}
	}
    .area {
		margin: 16rpx 0 32rpx;
		background-color: #F7F7F7;
		height: 144rpx;
		border-radius: 4rpx;
		box-sizing: border-box;
		padding: 16rpx 0;
	}
	.line_bottom {
		margin: 0 0 32rpx;
		height: 3rpx;
		background-color: #EEEEEE;
		overflow: hidden;
	}
	.btns {
		width: 100%
	}
	.btn {
		// width: 100rpx;
		padding: 0 18rpx;
		height: 44rpx;
		line-height: 40rpx;
		font-size: 24rpx;
		color: #808080;
		box-sizing: border-box;
		text-align: center;
		border-radius: 4px;
		border: 2rpx solid #E5E5E5;
	}

	.publish_btn {
		position: fixed;
		left: 50%;
		transform: translateX(-199rpx);
		bottom: 48rpx;
		background-color: #EE212D;
		border-radius: 100rpx;
		color: #fff;
		width: 398rpx;
        height: 98rpx;
		line-height: 98rpx;
		color: #fff;
		text-align: center;
		box-shadow: 0px 3px 8px 0px #F50F1E;
		z-index: 999
	}
	.enter_limit {
		word-break: break-all;
		max-width: 390rpx;
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
	}
</style>
